﻿var grid;
var varIncrementer = 0;
var v_CollectionID = varIncrementer++,
        v_InvoiceID = varIncrementer++,
        v_Remarks = varIncrementer++,
        v_Sr = varIncrementer++,
        v_Action = varIncrementer++,
        v_CompanyName = varIncrementer++,
        v_ClientName = varIncrementer++,
        v_ContractName = varIncrementer++,
        v_InvoiceNo = varIncrementer++,
        v_CollectionNo = varIncrementer++,
        v_CollectionDate = varIncrementer++,
        v_CollectionType = varIncrementer++,
        v_DrawnOnBank = varIncrementer++,
        v_RefNo = varIncrementer++,
        v_Amount = varIncrementer++,
        v_TDSAmount = varIncrementer++,
        v_GrossAmount = varIncrementer++;

$(document).ready(function () {
    $('#cboCompany').select2();
    $('#cboClient').select2();
    $('#cboContract').select2();
    $('#cboPaymentMode').select2();
    $('#cboFinancialYear').select2();
     
    $('#cboCompany').focus();
});

function fn_GetSearchResult(p_vTrack, p_objResult) {
    if (p_vTrack == "0") {
        callBack('GetSearchResult', 'cboCompany@cboContract@cboClient@cboPaymentMode@txtContractNo@txtInvoiceNo@txtInvoiceStartDate@txtInvoiceEndDate@txtReceivableStartDate@txtReceivableEndDate@cboFinancialYear');
    }
    else {
        document.getElementById("divResult").innerHTML = p_objResult.grdResult;
    }
    return false;
}


/**** Regular Expression Validator *****/
function fn_RegExpValidator(p_obj, p_args) {
    p_args.IsValid = true;
    var varCntl = $("#" + p_obj.controltovalidate);
    if (varCntl.attr("type") == "text") {
        if (varCntl.val() != "") {
            var vValidation = fn_ValidateExpression(varCntl.val(), $(p_obj).attr("expressionid"));
            if (vValidation != "") {
                args.IsValid = false;
                sender.childNodes['0'].innerHTML = vValidation;
            }
        }
    }
    return p_args.IsValid;
}

function getResponse(returnVal) {
    try {
        hideLoader(returnVal);
        var objResult = $.parseJSON(returnVal);
        if (objResult.SessionTimeOut == "1") {
            window.location.href = 'login.aspx';
        }
        else {
            var varTrack = objResult.Track;

            if (objResult.Track == "GetSearchResult") {
                fn_GetSearchResult("1", objResult);
            }
        }
    }
    catch (ex) {
        show_globalMessage('Error', 'error');
    }
}
